#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "./Peers.h"


void error( const char * msg )
{
	perror(msg);
	exit(1);
}

int main (int argc, char* argv[])
{
	int srvSocket;
	int portNo;
	int cliSocket;
	socklen_t clientLen;
	char* addr;
	char msgBuff[256];
	struct sockaddr_in srv_addr;
	struct sockaddr_in cli_addr;
	FILE * fp;
	char * file;
	char * filename;
	Peer p;
	int insertStat = 0;
	int isOwner = 0;
	char* port;
	
	// only 1 argument ./peer --> port not given
	if(argc < 2)
	{
		fprintf(stderr, "No Port Avalable!\n");
		exit(1);	
	}
	// 3 or more arguments ./peer [PORT] [filename]
	else if (argc > 2 )
		filename = argv[2];
	// 2 arguments only - no filename given	
	else filename = "";

	port = argv[1];
	p.initialize("./ListPeers.txt", port);
	p.join();
	return 1;
}
